#include <string>
#include <iostream>
#include <sstream>
#include "Student.h"
#include "StudentRegister.h"

using namespace std;

int main3_1()
{
	cout << "Uppgift 3.1" << endl;
	Student s1, s2("Alice", "Anderson", 2008);

	s1.SetFirstName("Bob");
	s1.SetSecondName("Masterson");
	s1.SetEnrollmentYear(2010);

	cout << s1.GetFirstName() << " " << s1.GetSecondName() << ", " << s1.GetEnrollmentYear() << endl;
	cout << s2.GetFirstName() << " " << s2.GetSecondName() << ", " << s2.GetEnrollmentYear() << endl;

	return 0;
}

int main3_2()
{
	cout << "Uppgift 3.2" << endl;
	Student s1, s2("Alice", "Anderson", 2008);
	s1.Read();

	s1.Write();
	s2.Write();
	

	return 0;
}

int main3_3()
{
	cout << "Uppgift 3.3" << endl;
	Student s1, s2("Alice", "Anderson", 2008);

	istringstream iss("Bob Masterson, 2010");
	iss >> s1;
	cout << s1;
	cout << s2;

	return 0;
}

int main3_4()
{
	cout << "Uppgift 3.4" << endl;
	Student s1, s2("Alice", "Anderson", 2008), s3("Trudy", "Intruderson", 2010);
	StudentRegister srRegister;
	istringstream iss("Bob Masterson, 2010");
	iss >> s1;

	srRegister.Add(s1);
	srRegister.Add(s2);
	srRegister.Add(s3);

	cout << srRegister.List() << endl;

	return 0;
}

int main3_5()
{
	cout << "Uppgift 3.5" << endl;
	Student s1, s2("Alice", "Anderson", 2008), s3("Trudy", "Intruderson", 2010);
	StudentRegister srRegister;
	istringstream iss("Bob Masterson, 2010");
	iss >> s1;

	srRegister.Add(s1);
	srRegister.Add(s2);
	srRegister.Add(s3);

	srRegister.WriteToFile("Studentregister.txt");

	return 0;
}

int main3_6()
{
	cout << "Uppgift 3.6" << endl;
	StudentRegister srRegister;
	srRegister.ReadFromFile("Studentregister.txt");

	cout << srRegister.List() << endl;

	return 0;
}

int main()
{
	// main3_1();
	// main3_2();
	// main3_3();
	// main3_4();
	main3_5();
	main3_6();

	system("PAUSE");
	return 0;
}